﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BB.SoundCloudWebPlayer.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;

namespace BB.SoundCloudWebPlayer.Drivers
{
    public class SoundCloudWebPlayerDriver : ContentPartDriver<SoundCloudTrackPart>
    {
        protected override DriverResult Display(
            SoundCloudTrackPart part, string displayType, dynamic shapeHelper)
        {
            return ContentShape("Parts_SoundCloudTrack", () => shapeHelper.Parts_SoundCloudTrack(
                        TrackName: part.TrackName,
                        TrackLocation: part.TrackLocation
                   ));
        }

        protected override DriverResult Editor(SoundCloudTrackPart part, dynamic shapeHelper)
        {
            return ContentShape("Parts_SoundCloudTrack_Edit",
                        () => shapeHelper.EditorTemplate(
                                TemplateName: "Parts/SoundCloudTrack",
                                Model: part,
                                Prefix: Prefix
                              )
                   );
        }

        protected override DriverResult Editor(SoundCloudTrackPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            updater.TryUpdateModel(part, Prefix, null, null);
            return Editor(part, shapeHelper);
        }
    }
}